<?php
class Admin_Model_DbTable_accomodation extends Zend_Db_Table_Abstract
{
	 protected $_name = 'hae_bdd_accomodation';
	 protected $_sequence=true;
     protected $_primary='id';
     protected $_dependentTables=array('Admin_Model_DbTable_city');
	public function addaccomodation($name_vi, $name_en, $name_ja, $name_cn, $name_fr)
	{
		$data = array(
		'name_vi' => $name_vi,
		'name_en' => $name_en,
		'name_ja' => $name_ja,
		'name_cn' => $name_cn,
		'name_fr' => $name_fr,
		);
		$this->insert($data);
	}
	public function getAll()
	{
		try {
			$select = $this->select();
			$select->from($this->_name, array("id","name_en"));
			return $this->fetchAll($select);
		}catch(Zend_Exception $e)
		{
			echo $e->getMessage();
		}
	}
	public function getaccomodation($id)
	{
	    $id = (int)$id;
	    $row = $this->fetchRow('id=' . $id);
		if(!$row)
		{ 
			throw  new Exception("Could not find row {$id}");
		}
		return $row->toArray();
	}
	public function updateaccomodation($id, $name_vi, $name_en, $name_ja, $name_cn, $name_fr)
	{
		$data = array(
		'name_vi' => $name_vi,
		'name_en' => $name_en,
		'name_ja' => $name_ja,
		'name_cn' => $name_cn,
		'name_fr' => $name_fr,
		);
		$this->update($data, 'id = '. (int)$id);
	}
	public function changestatus($id,$status)
	{
		$data = array(
				'status' => $status,
		);
		$this->update($data, 'id = '. (int)$id);
	}
	public function deleteaccomodation($id)
    {
        return $this->delete('id =' . (int)$id);
    }
}
?>